<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html;charset=utf-8"%>
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>登录 - 当当网</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="${pageContext.request.contextPath}/css/login.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/css/page_bottom.css" rel="stylesheet" type="text/css" />

	</head>
	<body>


		<%@include file="../common/head1.jsp"%>

		<div class="enter_part">

			<%@include file="../common/introduce.jsp"%>

			<div class="enter_in">
				<div class="bj_top"></div>
				<div class="center">
					<div style="height: 30px; padding: 5px; color: red" id="divErrorMssage">
					
					</div>
					<div class="main">
						<h3>
							登录当当网
						</h3>

						<form method="post" action="${pageContext.request.contextPath}/user/login.do" id="ctl00" onsubmit="return checkForm()">
							<ul>
								<li>
									<span>请输入Email地址：</span>
									<input type="text" name="email" id="txtUsername" class="textbox" onblur="checkEmail()"/>
								</li>
								<span id="emailSpan"></span>
								<li>
									<span class="blank">密码：</span>
									<input type="password" name="password" id="txtPassword" onblur="checkPwd()"
										class="textbox" />
								</li>
								<span id="pwdSpan"></span>
								<li>
									<input type="submit" id="btnSignCheck" class="button_enter"
										value="登 录" />
								</li>
								<c:if test="${param.error == -1}">
									<span style="color: red;">邮箱或密码输入错误</span>
								</c:if>
							</ul>
							<input type="hidden" name="uri" value="${uri}" />
						</form>
					</div>
					<div class="user_new">
						<p>
							您还不是当当网用户？
						</p>
						<p class="set_up">
							<a href="register_form.jsp">创建一个新用户&gt;&gt;</a>
						</p>
					</div>
				</div>
			</div>
		</div>

		<%@include file="../common/foot1.jsp"%>
		<script type="text/javascript">
			function checkEmail() {
				let email = document.querySelector("#txtUsername").value;
				let s = document.querySelector("#emailSpan");
				let reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
				if(reg.test(email)){
					s.innerHTML = "";
					return true;
				}else{
					s.innerHTML = "邮箱格式输入错误";
					s.style.color = "red";
					return false;
				}
			}
			function checkPwd() {
				let pwd = document.querySelector("#txtPassword").value;
				let s = document.querySelector("#pwdSpan");
				let reg = /\w{6,20}/
				if(reg.test(pwd)){
					s.innerHTML = "";
					return true;
				}else{
					s.innerHTML = "密码由大小写英文字母、数字组成，长度6－20位";
					s.style.color = "red";
					return false;
				}
			}
			function checkForm() {
				if(checkEmail() && checkPwd()){
					return true;
				}
				return false;
			}
		</script>
	</body>
</html>